Subject: Loading scenes into Modeler macro
From: [email-masked]
To: [email-masked]
Date: Wed, 9 Aug 95 16:59:27 PDT

Here's a macro I wrote which loads scenes into Modeler. Handy for things
like loading the posed Humanoid into Modeler, modeling with sized and
positioned scene objects available etc.
    
Cut here
-------------------------------------------------------------------------
/* CMD:Sceneload */
/* Loads objects from Lightwave scene, maintains hierarchy */
/* Brought to you by the Texas Chainsaw Massacre School of Programming */
/* [email-masked] */
/* Call the UNBORED BBS (908) 291-0126 */
/* */
/* */
/* Note:To load objects deformed by Bones, you must use Save */
/* Transformed in Layout. This macro will load the position, */
/* rotation, size and pivot point changes of any object */
/* including those with bones or displacement maps, but */
/* not the Bone or Displacement map deformations themselves. */
signal on error
signal on syntax
call addlib( "LWModelerARexx.port", 0 )
 
phile = GETFILENAME("Scene file to load as one object", "Toaster:Scenes" )
  
 if ~open('thisfile', phile, 'r') then do
    call close('thisfile')
    call notify(1,"!Say what? Something wrong with that filename. Load
 aborted.")
    exit
    end
/* This routine makes a list of the line numbers of the load object lines */
/* Since different objects have different amounts of data lines */
/* this keeps a record of where each object begins. Used to reference */
/* info on parent objects */
 momdad = 0
 loadflag = 0
 list = ""
 parent = ""
 point = ""
 pivot = 0
verzion = 0
line = readln('thisfile')
count = 1
do while ~eof('thisfile')
 parse var line first second
 if first = "LoadObject" then do
   list = list count
  end
 if first = "AddNullObject" then do 
   list = list count
   end
 if first = "ParentObject" then do
  parent = parent second
  momdad = 1
  end
 if first = "ShowObject" then do
   verzion = 1
  end  
 
 if first = "PivotPoint" then do
  point = point count
  pivot = 1
  end
 if first = "ShadowOptions" then do 
 if momdad = 0 then do 
 parent = parent||"0"
 end
 if pivot = 0 then do
 point = point||"0"
 end
 if verzion = 1 then
  skipdown = 5
  else 
  skipdown = 4
 
 end
 
line = readln('thisfile')
count = count +1
end
parent = strip(parent,'L',' ')
list = strip(list,'L',' ')
point =strip(point,'L',' ')
call close('thisfile')

 
/* Part2 - Getting the objects and positioning them */
 
 if ~open('thisfile', phile, 'r') then do
    call close('thisfile')
    call notify(1,"say what?")
    exit
    end
 
/* read the first line in */
 lion = readln('thisfile')
dracula = 1 /* the Count */
do while ~eof('thisfile')
/* divide the line into 2 variables */ 
/* when you get to a load object line, load the file */
parse var lion furst sekond
 if furst = "LoadObject" then do
 
 call setlayer(2)
 sekond = strip(sekond,'L',' ')
 relative = left(sekond,8)
 if (relative = "OBJECTS/") then sekond = "Toaster:"sekond
 if (relative = "Objects/") then sekond = "Toaster:"sekond
 if (relative = "objects/") then  sekond = "Toaster:"sekond 
 if ~open('fisle',sekond,'r') then do
  call notify(1, '!Problem with the file name with scene file.')
  call close('fisle')
  exit
  end
  call close('fisle')
   call load(sekond)
  /* 5 lines down from the Load Object line is the position etc. info */
   do  i = 1 to skipdown
   lion = readln('thisfile')
   end
 /* Put the info into variables */    
 parse var lion EX WHY ZEE H P B SX SY SZ
  numba = dracula
  call checkpoint()
  dracula = dracula + 1
 call transformations()
 
  lion = readln('thisfile')
  parse var lion keyword argument
    do until keyword = "ShadowOptions"
    /* do until end of object section */
    /* read lines from file */
    
    /* divide lines into 2 variables */
    parse var lion ferst zekond
    /* if you find a Parent Object line in an object section */
       if ferst = "ParentObject" then do
        call heritage()
        /* check parent list to see if parent has parent */
        nextparent = word(parent,zekond)
         do while nextparent > 0 
          
          zekond = nextparent
          call heritage()
          nextparent = word(parent,zekond)
          end
        end 
    lion =readln('thisfile')    
     parse var lion keyword argument
    end 
 
  call cut()
  call setlayer(1)
  call paste()
  
 end
    
lion = readln('thisfile')
end

exit
heritage:
    /* use the object number of the parent object to extract the line */
    /* number of where that parent object's info begins */ 
     linenumber = word(list,zekond)
    /* add 5 to compute line of info */
      linenumber = linenumber + skipdown
    call flipthrough() 
     /* pull the info from that line */  
      parse var zip EX WHY ZEE H P B SX SY SZ
  numba = zekond
  call checkpoint()
   call transformations()

return 
checkpoint:
 /* extract line number of Pivot Point info */
  linenumber = word(point,numba)
     if linenumber > 0 then do
     call flipthrough()
      parse var zip DISCARD EXP WHYP ZEEP
     /* move the pivot point */
      call move((-EXP) (-WHYP) (-ZEEP))
     end
  return
   
flipthrough:
    /* open another logical file */
    /* read lines 'til you get to the one you want */
      call open('fileagain',phile,'r')
      do thumbthrough = 1 to linenumber
      zip = readln('fileagain')
      end
      call close('fileagain')
      
 return
transformations:
  call MOVE(EX WHY ZEE)
  call ROTATE(-B,Z,EX WHY ZEE)
  call ROTATE(-P,X,EX WHY ZEE)
  call ROTATE(-H,Y,EX WHY ZEE)
 call SCALE(SX SY SZ, EX WHY ZEE) 
return     
syntax:
error:
   call end_all()
   call notify( 1, "!Rexx Script Error", "@"errortext( rc ), "Line "sigl )
   exit
--
[email-masked] sent this message.
To Post a Message           : [email-masked]
Un/Subscription Requests To : [email-masked]
(DIGEST)                 or : [email-masked]
Administrative Items To     : [email-masked]